Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed recovery. Fixes MER#1987 #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Thaodan
Copy link
Contributor

@Thaodan Thaodan commented Nov 19, 2018

Some devices like Sonys X series have no recovery partition on these devices the recovery needs to be inside the regular initramfs.

To do so we check if skip_initramfs hasn't been passed (read line 56) and then start the recovery.

Background:
Bootloaders for Android phones pass skip_init_ramfs when the system should be booted normally and don't pass it when the key combination for recovery mode was used.
We piggy back on this behavior by using the kernel commandline option is mostly the samen way except that we always use a init-ramfs.

Copy link
Contributor

@sledges sledges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your contribution!

I haven't checked the changes in .sh for now

@@ -73,6 +75,12 @@ BuildRequires: yamui
BuildRequires: openssh-clients
BuildRequires: openssh-server

%if 0%{?embed_recovery:1}
BuildRequires: shpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your contribution of shpp is appreciated, but I'm afraid it cannot be justified in the context of HW adaptation recovery, as we are trying to keep dependencies to a minimum. In this particular use-case a sed command should be sufficient.

%if 0%{?embed_recovery:1}
BuildRequires: shpp
%else
%define embed_recovery 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This renders some parts of the code unreachable, because defining something in .spec (even if equal to 0), counts as defined.
See here: https://backreference.org/2011/09/17/some-tips-on-rpm-conditional-macros/
and here: https://github.com/mer-hybris/droid-hal-device/blob/5fd1782c7f7b898fd66469d6cd43890c82219730/droid-hal-%40DEVICE%40.spec.template#L14

@@ -98,6 +106,7 @@ Requires: oneshot
%description
%{summary}

%if 0%{!?embed_recovery:1}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, this %if never evaluates to true, because embed_recovery is now always defined (either to 1, or to 0). This also applies to all similar statements against embed_recovery below

popd
%{mkbootimg_cmd} hybris-boot.img

%{mkbootimg_cmd} hybris-boot.img
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space at the end of the line (makes the diff a bit unclear)

@@ -17,6 +17,8 @@
# battery_capacity_file: Path to read current battery charge from.
# battery_capacity_threshold: Battery threshold for factory reset [0, 100].
# Default 0 (no threshold).
# embed_recovery: in case the recovery needs to embeded inside
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking a typo: "needs to be embedded"

@Thaodan
Copy link
Contributor Author

Thaodan commented Nov 19, 2018 via email

@sledges
Copy link
Contributor

sledges commented Nov 20, 2018

How can I default to an alternative value like in shell Scripts with ${too:-bar} ?

%{?foo}%{!?foo:bar}, e.g. %{?embed_recovery}%{!?embed_recovery:0}

About the dependencies , how would you do this with just sed? I'm not sure how to do this in a clean way.

sed "s/@EMBED_RECOVERY@/%{?embed_recovery}%{!?embed_recovery:0}/g" -i %{_local_initrd_dir}/jolla-init

@sledges
Copy link
Contributor

sledges commented Nov 29, 2018

sed "s/@EMBED_RECOVERY@/%{?embed_recovery}%{!?embed_recovery:0}/g" -i %{_local_initrd_dir}/jolla-init

Below link is the complete rewrite without sed, I have not fully tested on a running device yet, as I have some doubts about this line: sledges@58ab8a4#diff-ae5e5322c8e93e423e4ef2ac5e20cd84R101
Will test when I find time ASAP, probably early next week.

Apologies for coming back on this only now, but github does not send emails about updated PR. We're lucky I was checking my timesheed as it's the end of the month, and found your PR again:)

@Thaodan Thaodan force-pushed the embed_recovery branch 2 times, most recently from a4339d3 to 9ecb179 Compare November 29, 2018 23:01
@Thaodan
Copy link
Contributor Author

Thaodan commented Nov 29, 2018

@sledges No problem. I fixed that line that you mean in mksfosinitrd and cleaned that feature a bit up.
About the actual init script to you want the embed recovery code to be present when embed recovery is not used or not present when its not used (shpp solution)?

In case the recovery needs to embeded inside the regular initramfs.
@@ -202,11 +212,13 @@ touch %{buildroot}/lib/modules/%{kernelver}/{modules.order,modules.builtin}
%defattr(-,root,root,-)
/boot/hybris-boot.img
%defattr(644,root,root,-)
/lib/modules/%{kernelver}
/Li/modules/%{kernelver}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo?

@Thaodan
Copy link
Contributor Author

Thaodan commented Jun 22, 2019 via email

@Olf0
Copy link

Olf0 commented Aug 30, 2021

This was looking well on its way and close to be ready for merging, after the many fixes and improvements above.
@sledges & @Thaodan, is there a specific reason, why this has been stalling for more than 2 years?

@Olf0
Copy link

Olf0 commented Sep 5, 2021

The reason why iI am asking, is that

  1. The "Changes requested" displayed below are the ones @sledges requested on 19 Nov 2018: AFAICS these have been addressed. Hence @sledges' open ToDos might be to perform his "I haven't checked the changes in .sh for now" to finish his review and ultimately close the open review process.
  2. @Thaodan's last comment is "Yes fixed." on 22 Jun 2019, hence I assume he sees no open issues with this MR for more than two years now.
  3. Because this MR has been stalled for more than two years, meanwhile merges now result in merge conflicts and created the need to re-base. This will only become worse, if the stalling continues.
  4. The Xperia 10 II is the first device officially supported by Jolla, which needs an "embedded recovery". As its support was announced and deployed in early 2021, resolving this issue (MER#1987) is crucial in order to cease offering the clumsy, current official advice to stubbornly flash the recovery image, use it and then re-flash the boot image.

@sledges
Copy link
Contributor

sledges commented Sep 6, 2021

This was looking well on its way and close to be ready for merging, after the many fixes and improvements above.
@sledges & @Thaodan, is there a specific reason, why this has been stalling for more than 2 years?

The reason is that such change needs to be tested on all Jolla's supported devices to avoid regressions, and in case such risk is minimal and/or this functionality is not enabled in a given kernel, the work of updating submodule for each device is still required.

Since we had had a workaround for recovery, this PR was not on a critical path and thus turned into technical debt, due to other priorities.
It has certainly become more actual with releasing Xperia 10 II, and we will adjust prioritisation accordingly as possible. For now please use the workaround [1], which is, agreed, more involving than other Xperias, nevertheless recovery mode is (and should) not be a frequently used feature.

[1] https://jolla.zendesk.com/hc/en-us/articles/360021620740

@Olf0
Copy link

Olf0 commented May 28, 2022

[…] this PR […] turned into technical debt, due to other priorities. It has certainly become more actual with releasing Xperia 10 II, and we will adjust prioritisation accordingly as possible.

… and even more so by releasing SailfishOS for the Xperia 10 III recently.

@Thaodan
Copy link
Contributor Author

Thaodan commented Aug 18, 2022

Summary of what has to be done to use this PR.

  1. Rebase the PR (cc me :) )
  2. Update the droid-hal-img-boot submodule to use this patch/branch, (%define embed_recovery)
  3. Make sure that Ignore skip_initramfs is still passed but doesn't do anything on your devices kernel. For the Xperia XA2 this PR can be used:
    Revert Ignore skip_initramfs for now but keep kernel option MER#1988 android_kernel_sony_msm#26
    This commit contains the required change:
    mer-hybris/android_kernel_sony_msm@c73ed25

Both droid-hal and droid-hal-img-boot have to be build after applying the changes mentioned above, after doing so flashing hybris_boot.img is enough to test if the PR works.

@Thaodan
Copy link
Contributor Author

Thaodan commented May 31, 2024

This PR is obsolete for devices using Android 12 and up.
It was never required for devices using a dedicated recovery partition (refer to the graph above for devices starting with Android 13):
https://source.android.com/docs/core/architecture/partitions/generic-boot#figure-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants